package base.sort;

import java.util.Arrays;

public class quikSort {

    public static void qSort(int[] arr, int l, int r) {
        if (l >= r) return;
        int pivot = l;
        int key = arr[pivot];
        int i = l;
        int j = r;
        while (i < j) {
            while (i < j && arr[j] >= key) j--;
            arr[pivot] = arr[j];
            pivot = j;
            while (i < j && arr[i] <= key) i++;
            arr[pivot] = arr[i];
            pivot = i;
        }
        pivot = i;
        arr[pivot] = key;
        qSort(arr, l, pivot - 1);
        qSort(arr, pivot + 1, r);
    }

    public static void main(String[] args) {

        int[] arr = {4,2,22,3,123,11,2,1,0,2282,21,4343,111,33};
        qSort(arr, 0, arr.length - 1);
        Arrays.stream(arr).forEach(System.out::println);

        String s = "1223";
        s.replace("2", "-");
        System.out.println(s);
        System.out.println(s.indexOf("22"));

    }








}
